package com.asohofrucol.dto.util;
import com.asohofrucol.dto.VisitDataItemDTO;
import com.asohofrucol.model.ComboValue;
import com.asohofrucol.model.TechnicalAssistanceField;
import com.asohofrucol.model.TechnicalAssistanceItem;
import com.asohofrucol.model.TechnicalAssistanceVisit;

public class VisitDataItemHelperDto {

	public static VisitDataItemDTO convertToRegisterDTO(TechnicalAssistanceItem ag){
		VisitDataItemDTO dto = new VisitDataItemDTO();
		dto.setId(ag.getId());
		dto.setTechnicalAssistanceVisitId(ag.getTechnicalAssistanceVisit().getId());
		dto.setValue((ag.getComboValueRowValueId()!=null)?ag.getComboValueRowValueId().getId():null);
		dto.setValueTxt(ag.getRowValueTxt());
		dto.setRowId(ag.getComboValueRowNameId().getId());
		dto.setFieldId(ag.getTechnicalAssistanceField().getId());
		return dto;
	}
	
	public static TechnicalAssistanceItem converRegisterToEntity(VisitDataItemDTO agDTO){
		TechnicalAssistanceItem ag = new TechnicalAssistanceItem();
		ag.setId(agDTO.getId());
		ag.setTechnicalAssistanceVisit(new TechnicalAssistanceVisit(agDTO.getTechnicalAssistanceVisitId()));
		ag.setComboValueRowValueId(new ComboValue(agDTO.getValue()));
		ag.setRowValueTxt(agDTO.getValueTxt());
		ag.setComboValueRowNameId(new ComboValue(agDTO.getRowId()));
		ag.setTechnicalAssistanceField(new TechnicalAssistanceField(agDTO.getFieldId()));
		return ag;
	}
}
